package com.ruoyi.view.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.view.domain.AirQualityCount;
import com.ruoyi.view.service.IAirQualityCountService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * air_quality_countController
 *
 * @author ruoyi
 * @date 2023-04-11
 */
@Controller
@RequestMapping("/view/quality")
public class AirQualityCountController extends BaseController
{
    private String prefix = "data-analysis/quality_count";

    @Autowired
    private IAirQualityCountService airQualityCountService;

    @RequiresPermissions("data-analysis:quality_count:view")
    @GetMapping()
    public String quality_count()
    {
        return prefix + "/quality_count";
    }

    /**
     * 查询air_quality_count列表
     */
//    @RequiresPermissions("data-analysis:quality_count:list")
    @CrossOrigin
    @RequestMapping("/list")
    @ResponseBody
    public TableDataInfo list(AirQualityCount airQualityCount)
    {
//        startPage();
        List<AirQualityCount> list = airQualityCountService.selectAirQualityCountList(airQualityCount);
        return getDataTable(list);
    }

    /**
     * 导出air_quality_count列表
     */
    @RequiresPermissions("data-analysis:quality_count:export")
    @Log(title = "air_quality_count", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AirQualityCount airQualityCount)
    {
        List<AirQualityCount> list = airQualityCountService.selectAirQualityCountList(airQualityCount);
        ExcelUtil<AirQualityCount> util = new ExcelUtil<AirQualityCount>(AirQualityCount.class);
        return util.exportExcel(list, "air_quality_count数据");
    }

    /**
     * 新增air_quality_count
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存air_quality_count
     */
    @RequiresPermissions("data-analysis:quality_count:add")
    @Log(title = "air_quality_count", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AirQualityCount airQualityCount)
    {
        return toAjax(airQualityCountService.insertAirQualityCount(airQualityCount));
    }

    /**
     * 修改air_quality_count
     */
    @RequiresPermissions("data-analysis:quality_count:edit")
    @GetMapping("/edit/{airQuality}")
    public String edit(@PathVariable("airQuality") String airQuality, ModelMap mmap)
    {
        AirQualityCount airQualityCount = airQualityCountService.selectAirQualityCountByAirQuality(airQuality);
        mmap.put("airQualityCount", airQualityCount);
        return prefix + "/edit";
    }

    /**
     * 修改保存air_quality_count
     */
    @RequiresPermissions("data-analysis:quality_count:edit")
    @Log(title = "air_quality_count", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AirQualityCount airQualityCount)
    {
        return toAjax(airQualityCountService.updateAirQualityCount(airQualityCount));
    }

    /**
     * 删除air_quality_count
     */
    @RequiresPermissions("data-analysis:quality_count:remove")
    @Log(title = "air_quality_count", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(airQualityCountService.deleteAirQualityCountByAirQualitys(ids));
    }
}
